

import 'package:flutter_ohos/generated/json/base/json_convert_content.dart';

class BaseResponseEntity<T>{
  late final bool success;
  late String message;
  late final dynamic code;
  dynamic rawJsonValue;
  T? data;
  BaseResponseEntity({
    required this.data,
    required this.code,
    required this.message,
    required this.success,
  });

  BaseResponseEntity.fromJson(Map<String, dynamic> json) {
    if (json['data'] != null&&json['data']!='null') {
      if (json['data']! is String) {
        data = json['data'];
      } else {
        data = JsonConvert.fromJsonAsT<T>(json['data']) as T;
      }

    }
    code = json['code'];
    if(json['message']== null){
      message = "";
    } else {
      message = json['message'];
    }

    if(json['msg']!= null){
      message = json['msg'];;
    }

    if(json['success']== null){
      success = json['status'] == 1? true:false;
    } else {
      success = json['success'];
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (this.data != null) {
      data['data'] = this.data;
    }
    data['code'] = code;
    data['message'] = message;
    data['success'] = success;
    return data;
  }

}

